import requests

def get_session(uname, upass):
    login_url = 'http://localhost:192.168.1.73/YunDuanBoss/login/userLogin'
    login_data = {'userName': uname, 'userPass': upass, 'checkcode': '0000', 'remember': 'y'}
    session.post(url=login_url, data=login_data)
    return session

def add_emp(work_id):
    add_emp_url = 'http://localhost:192.168.1.73/YunDuanBoss/employee/addEmp'
    add_emp_data = {
        "emp.region_id": "3",
        "emp.department_id": "16",
        "emp.position": "",
        "emp.employee_name": "王莉莉10",
        "emp.sex": "女",
        "emp.entry_time": "",
        "emp.tel": "",
        "emp.email": "",
        "emp.qq": "",
        "emp.education": "",
        "emp.university": "",
        "emp.major": "",
        "emp.address": "",
        "emp.source": "",
        "emp.cardnum": "",
        "emp.identity": "",
        "emp.birthday": "",
        "emp.birthday_type": "01",
        "emp.emergency_contact": "",
        "emp.emergency_tel": "",
        "emp.emegency_relation": "",
        "emp.work_id": work_id
    }
    resp = session.post(url=add_emp_url, data=add_emp_data)
    print(resp.text)

def grant_role():
    grant_role_url = 'http://localhost:192.168.1.73/YunDuanBoss/user/saveSetRole'
    grant_role_data = {
        "userId": "196",
        "roleId[]": "18"
    }
    resp = session.post(url=grant_role_url, data=grant_role_data)
    print(resp.text)

def modifypwd1():
    checkoldpass_url = 'http://localhost:192.168.1.73/YunDuanBoss/resource/checkOldPass'
    checkoldpass_data = {
        "pass": "woniu123",
        "newPass": "YUNduan123"
    }
    checkoldpass_resp = session.post(url=checkoldpass_url, data=checkoldpass_data)
    print(checkoldpass_resp.text)

    modifypassword_url = 'http://localhost:192.168.1.73/YunDuanBoss/resource/modifyPassword'
    modifypassword_data = {
        "pass": "YUNduan123"
    }
    modifypassword_resp = session.post(url=modifypassword_url, data=modifypassword_data)
    print(modifypassword_resp.text)

def modifypwd2():
    checkoldpass2_url = 'http://localhost:192.168.1.73/YunDuanBoss/resource/checkoldpass2'
    checkoldpass2_data = {
        "pass": "woniu123",
        "newPass": "YUNduan123"
    }
    checkoldpass2_resp = session.post(url=checkoldpass2_url, data=checkoldpass2_data)
    print(checkoldpass2_resp.text)

    modifypass2_url = 'http://localhost:192.168.1.73/YunDuanBoss/resource/modifypass2'
    modifypass2_data = {
        "pass": "YUNduan123"
    }
    modifypass2_resp = session.post(url=modifypass2_url, data=modifypass2_data)
    print(modifypass2_resp.text)


if __name__ == '__main__':

    session = get_session('YDHR000', 'yunduan123')
    add_emp('YDXA586')

